<!DOCTYPE html>
<html class="no-js" lang="">

<head>
    #include( "/public-head.html")


</head>

<body style="background-color: #ffffff !important;">

<div class="main-content" >
    <div class="panel" >
        <div class="panel-body" >
            <form action="/vrs/video/golist.html" id="seachForm" class="seach-form">
                <ul class="pager pager-square pull-left">
                    <li >
                        <span>id：<input name="video.videoId"  value="$!{video.videoId}"  style="width: 30px;"></span>
                    </li>
                    <li >
                        <span>名称：<input name="name" id="channelName" value="$!{video.name}"  style="width: 60px;"></span>
                    </li>
                    <li >
                        频道：
                        <select id="channelSelect"  data-placeholder="请选择频道" class="chosen w100" name="video.album.channel.channelId">
                            <option value="">全部</option>
                            #if($channelList)
                            #foreach( $row in $!{channelList})
                            <option value="$!{row.channelId}">$!{row.name}</option>
                            #end
                            #end
                        </select>

                    </li>
                    <li >
                        专辑：
                        <select id="albumSelect"  data-placeholder="请选择专辑" class="chosen w150" name="video.album.albumId">
                            <option value="">全部</option>
                            #if($albumList)
                            #foreach( $row in $!{albumList})
                            <option value="$!{row.albumId}">$!{row.name}</option>
                            #end
                            #end
                        </select>

                    </li>

                    <li>
                        上线状态：
                        <select id="isdisplaySelect"  data-placeholder="请选择" class="chosen" style="width: 70px;" name="video.isdisplay">
                            <option value="">全部</option>
                            <option value="1">上线</option>
                            <option value="0">下线</option>
                            <option value="2">处理中</option>
                        </select>

                    </li>
                    <li>
                        视频类型：
                        <select id="videoTypeSelect"  data-placeholder="请选择" class="chosen" style="width: 70px;" name="video.videoType">
                            <option value="">全部</option>
                            #if($videoTypeList)
                            #foreach( $row in $!{videoTypeList})
                            <option value="$!{row.code}">$!{row.name}</option>
                            #end
                            #end
                        </select>

                    </li>
                    <li>
                        <button title="搜索" type="submit"  class="btn btn-icon-icon btn-sm btn-info" ><i class="fa fa-search"></i></button>
                    </li>

                </ul>
            </form>
            <ul class="pager pager-square pull-right">
                <button id="addvideo" title="添加" type="button" class="btn btn-info btn-sm btn-icon-icon mr5" data-url="/vrs/video/edit.html" id="add-video" data-text="添加视频" data-target="new" >
                    <i class="fa fa-plus"></i>
                </button>
                <button  class="btn btn-success btn-sm btn-icon-icon mr5 batch" ajax-url="/vrs/video/batch/display/1.jsn?videoIds=" title="批量上线">
                    <i class="fa fa-angle-double-up"></i>
                </button>
                <button  class="btn btn-success btn-sm btn-icon-icon mr5 batch" ajax-url="/vrs/video/batch/display/0.jsn?videoIds=" title="批量下线" >
                    <i class="fa fa-angle-double-down"></i>
                </button>
                <button type="button" title="刷新" class="btn btn-info btn-sm btn-icon-icon mr5" data-url="/vrs/video/golist.html">
                    <i class="fa fa-spinner"></i>
                </button>
            </ul>
            <table id="listTable" class="table table-bordered bordered table-striped table-condensed vrs-table" data-url="golist.html"><!--datatable-->
                <thead>
                <tr>
                    <th><a href="#" class="csa select-all">全选</a>&nbsp;&nbsp;<a href="#" class="csa select-reverse">反选</a></th>
                    <th>配图</th>
                    <th>名称</th>
                    <th>专辑</th>
                    <th>类型</th>
                    <th>上线状态</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                #if($page)
                    #foreach( $row in $!{page.rows})
                    <tr>
                        <td><input type="checkbox" value="$!{row.videoId}">&nbsp;$!{row.videoId}</td>
                        <td class="pic-td">$!{row.standardPic}</td>
                        <td>$!{row.name}</td>
                        <td>$!{row.album.name}</td>
                        <td>
                            #if($!{row.videoType}==1)
                            整场
                            #end
                            #if($!{row.videoType}==2)
                            单曲
                            #end
                            #if($!{row.videoType}==3)
                            花絮
                            #end
                            #if($!{row.videoType}==4)
                            直播
                            #end
                            #if($!{row.videoType}==5)
                            秀场
                            #end
                        </td>
                        <td >
                            #if($!{row.isdisplay}==1)
                            上线
                            #end
                            #if($!{row.isdisplay}==0)
                            下线
                            #end
                            #if($!{row.isdisplay}==2)
                            处理中
                            #end
                        </td>
                        <td class="time-td">$!{row.modifyTime}</td>
                        <td>
                            <button title="编辑"  class="btn btn-icon-icon btn-sm btn-primary" data-url="/vrs/video/edit.html?videoId=$!{row.videoId}" id="edit-video-$!{row.videoId}" data-text="修改视频[$!{row.videoId}]" data-target="new"><i class="fa fa-edit"></i></button>
                            #if($!{row.videoType} ==4 || $!{row.videoType} ==5)
                            <button title="预览"  class="btn btn-icon-icon btn-sm btn-primary"  data-url="/vrs/video/one/live.jsn?videoId=$!{row.videoId}" id="live-video-$!{row.videoId}" data-text="观看直播[$!{row.videoId}]"  data-target="new"><i class="fa fa-video-camera"></i></button>
                            <button title="结束直播"  class="btn btn-icon-icon btn-sm btn-danger stop-live"  video-id="$!{row.videoId}" ><i class="fa fa-stop"></i></button>
                            #else
                            <button title="预览"  class="btn btn-icon-icon btn-sm btn-primary" data-toggle="modal" data-target=".play-video" video-id="$!{row.videoId}"><i class="fa fa-video-camera"></i></button>
                            #end

                            #if($!{row.isdisplay}==1)
                            <button title="下线"  class="btn btn-icon-icon btn-sm btn-primary" ajax-url="/vrs/video/display/$!{row.videoId}/0.jsn" ><i class="fa fa-arrow-down"></i></button>
                            #end
                            #if($!{row.isdisplay}==0)
                            <button title="上线"  class="btn btn-icon-icon btn-sm btn-primary" ajax-url="/vrs/video/display/$!{row.videoId}/1.jsn" ><i class="fa fa-arrow-up"></i></button>
                            #end
                            <!--<button title="删除" class="btn btn-icon-icon btn-sm btn-danger" ajax-url="/vrs/video/del/$!{row.videoId}.jsn"><i class="fa fa-remove"></i></button>-->

                        </td>
                    </tr>
                    #end
                #end
                </tbody>
            </table>
            <ul id="ul-page" class="pager pager-square pull-left" >
                <li >
                    <a href="" id="first-page" page="1">第一页</a><!--/vrs/video/list.jsn-->
                </li>
                <li >
                    <a href="" id="prev-page" page="$!{page.prevPage}">上一页</a><!--/vrs/video/list.jsn?page=$!{page.prevPage}-->
                </li>
                <li>
                    <a href="" id="next-page" page="$!{page.nextPage}">下一页</a><!--/vrs/video/list.jsn?page=$!{page.nextPage}-->
                </li>
                <li >
                    <a href="" id="last-page" page="$!{page.total}">最后一页</a><!--/vrs/video/list.jsn?page=$!{page.total}-->
                </li>
            </ul>
            <ul class="pager pager-square pull-right">
                <li >
                    <span><input name="page" style="border: none;background: none;width: 40px;"></span>
                </li>
                <li>
                    <a href="">跳转</a>
                </li>
                <li id="page-total">
                    <span>$!{page.page}/$!{page.total} 页</span>
                </li>
                <li id="total-rows">
                    <span>总共: $!{page.records} 条</span>
                </li>
            </ul>
        </div>
    </div>

</div>

#include( "/public-script.html")
#include( "/sub-script.html")
#parse("/play-video-modal.html")
<script>
    initEditSelect('channelSelect','$!{video.album.channel.channelId}');
    initEditSelect('albumSelect','$!{video.album.albumId}');
    initEditSelect('isdisplaySelect','$!{video.isdisplay}');
    initEditSelect('videoTypeSelect','$!{video.videoType}');
    $(function(){
        $('.stop-live').click(function(){
            var $this = $(this);
            swal({
                        title: '确认此操作吗?',
                        //text: 'You will not be able to recover this imaginary file!',
                        type: 'warning',
                        showCancelButton: true,
                        //confirmButtonColor: '#DD6B55',
                        confirmButtonText: '确定!',
                        closeOnConfirm: false,
                        cancelButtonText:'取消'
                    },
                    function () {
                        var videoId = $this.attr('video-id');
                        stopLive(videoId);
                    });

        });
    });

    /**
     * 关闭直播
     * @param videoId
     */
    function stopLive(videoId){
        $.get(LIVE_VIDEO_STOP+videoId,function(data,status){
            if(status == 'success'){
                var success = data.success;
                if(success){
                    //createVideoByLive(videoId);
                    swal('关闭成功', '直播录像正在后台生成', 'success');

                }else{
                    var msg = "关闭失败";// '直播类型暂不支持播放';
                    var type = 'error';
                    var $layout = 'topRight';
                    notyRestart(msg,type,$layout);
                }
            }
        });
    }
    /**
     * 关闭直播后生成相应的录播视频
     * @param videoId
     */
    function createVideoByLive(videoId){
        $.get(CREATE_VIDEO_BY_LIVE+videoId,function(data,status){
            if(status == 'success'){
                var success = data.success;
                if(success){
                    var msg = "直播录像生成成功，请刷新视频列表查看";//
                    var type = 'success';
                    var $layout = 'topRight';
                    notyRestart(msg,type,$layout);

                }else{
                    var msg = "录像生成失败";//
                    var type = 'error';
                    var $layout = 'topRight';
                    notyRestart(msg,type,$layout);
                }
            }
        });
    }
</script>
</body>

</html>
